/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package test;

import alg.Evaluation;
import grid.JobGraph;
import java.io.FileWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.jgap.Configuration;
import util.GridConf;
import util.Utils;

/**
 *
 * @author Dragan
 */
public class GridJdl1 {

    private static int SEASONS = 50;
    private static int ISLANDS = 20;
    private static int EPOCHS = 4;
    private static int MIGRATIONS_WIDTH = 1;
    private static int POPULATION_SIZE = 20;
    private static final String BREEDER_EXEC = "breeder.sh";
    private static final String MIGRATOR_EXEC = "migrator.sh";
    private static final String REQ0 = "(other.GlueCEUniqueID ==\"grid-ce.ii.edu.mk:2119/jobmanager-pbs-seegrid\")";
    private static final String REQ1 = "(other.GlueCEUniqueID == \"grid-lab-ce.ii.edu.mk:2119/jobmanager-pbs-seegrid\")";
    private static final String REQ2 = "(other.GlueCEUniqueID == \"ce01.afroditi.hellasgrid.gr:2119/jobmanager-pbs-seegrid\")";
    private static final String REQ3 = "(other.GlueCEUniqueID == \"ce02.grid.acad.bg:2119/jobmanager-pbs-seegrid\")";
    private static final String REQ4 = "(other.GlueCEUniqueID == \"ce01.grid.info.uvt.ro:2119/jobmanager-pbs-seegrid\")";
    private static final String REQ5 = "(other.GlueCEUniqueID == \"ce.ngcc.acad.bg:2119/jobmanager-pbs-seegrid\")";
    private static final String REQ6 = "(other.GlueCEUniqueID == \"ce001.grid.uni-sofia.bg:2119/jobmanager-lcgpbs-seegrid\")";
    private static final String REQ7 = "(other.GlueCEUniqueID == \"grid-lab-ce.ii.edu.mk:2119/jobmanager-pbs-seegrid\")";
    private static final String REQ8 = "(other.GlueCEUniqueID == \"yildirim.grid.boun.edu.tr:2119/jobmanager-lcgpbs-seegrid\")";
    private static final String REQ9 = "(other.GlueCEUniqueID == \"ce01.mosigrid.utcluj.ro:2119/jobmanager-pbs-seegrid\")";
    private static final String REQ10 = "(other.GlueCEUniqueID == \"ce002.ipp.acad.bg:2119/jobmanager-lcgpbs-seegrid\")";
    private static final String REQ11 = "(other.GlueCEUniqueID == \"ce.ulakbim.gov.tr:2119/jobmanager-lcgpbs-seegrid\")";
    private static final String REQ12 = "(other.GlueCEUniqueID == \"ce64.phy.bg.ac.yu:2119/jobmanager-pbs-seegrid\")";
    private static final List<String> REQS = new ArrayList<String>(Arrays.asList(new String[]{REQ1, REQ2, REQ3, REQ4, REQ5, REQ6, REQ7, REQ8, REQ9, REQ10, REQ11}));
    private static final String REMOTE_DIR = "17052009_c01411_1";
    private static final String REMOTE_PATH = "lfn:/grid/seegrid/dragansah/" + REMOTE_DIR + "/";

    public static void main(String[] args) throws Exception {
        Configuration conf = Utils.getDefaultConfiguration(POPULATION_SIZE,
                new Evaluation(GridConf.getDwConfiguration()));
        //for (int i = 0; i < ISLANDS; i++) {
        //Genotype population = Utils.getRandomGenotype(conf);
        //Utils.saveGenotypeToGZIP("gridapp/population" + (i + 1) + "_" + 1 + EXTENSION, population);
        //Utils.saveGenotypeToGZIP("world/population" + (i + 1) + "_" + 1 + EXTENSION, population);
        //Utils.saveGenotypeToGZIP("real/population" + (i + 1) + "_" + 1 + EXTENSION, population);
        //}

        JobGraph sampleJob = new JobGraph(ISLANDS, EPOCHS, SEASONS, MIGRATIONS_WIDTH);

        sampleJob.addInput("gridapp.jar");
        sampleJob.addInput("grid_queries");
        sampleJob.addInput("gridapp.sh");
        sampleJob.setExecutable("gridapp.sh");
        sampleJob.setVersion("0.2");
        sampleJob.setBreederExec("gridapp.sh");

        sampleJob.setDefaultNodeRetryCount(0);
        sampleJob.setDefaultNodeShallowRetryCount(3);
        sampleJob.addRequirement(REQ0);
        sampleJob.addRequirement(REQ1);


        System.out.println(sampleJob);
        FileWriter out = new FileWriter("gridapp/gridapp.jdl");
        out.write(sampleJob.toString());
        out.close();
    }
}
